<template>
  <el-dialog :close-on-click-modal="false" :visible.sync="companyDialogVisible">
    <el-form ref="companyForm" :model="queryCondition" label-width="6rem">
      <el-row :gutter="40">
        <el-col :span="8">
          <el-form-item label="公司名称">
            <el-input v-model="queryCondition.name" placeholder="公司名称" />
          </el-form-item>
        </el-col>
      </el-row>
      <SearchButton :default-params="params" @refreshParams="refreshParams" @getList="getList1" />
    </el-form>
    <div class="tableCard">
      <!-- 增删改查按钮放置位置 -->
      <div v-if="btnCheck" class="btnList">
        <div class="leftBtn" />
        <div class="rightBtn">
          <el-button type="success" icon="el-icon-plus" @click="openCompenyDetail('','0')">添加
          </el-button>
          <el-button type="primary" icon="el-icon-refresh" @click="getRentList()">刷新
          </el-button>
        </div>
      </div>
      <vxe-table
        ref="xTree"
        border
        stripe
        resizable
        highlight-hover-row
        :loading="loading"
        :data="companyList"
        height="500"
      >
        <vxe-table-column
          tree-node
          field="bunkCode"
          min-width="120"
          title="公司代码"
        />
        <vxe-table-column
          field="houseNumber"
          min-width="120"
          title="公司名称"
        />
        <vxe-table-column
          field="name"
          min-width="140"
          title="公司地址"
        />
        <vxe-table-column
          field="buildName"
          title="联系人"
          min-width="120"
        />
        <vxe-table-column
          field="floorName"
          title="联系电话"
          min-width="120"
        />
        <vxe-table-column
          v-if="operateCheck"
          title="操作"
          fixed="right"
          min-width="180"
          slots="default"
        >
          <template slot-scope="scope">
            {{ scope }}
            <label class="linkLable" @click="openCompenyDetail(scope.row.id,'1')">查看</label>
            <label class="linkLable" @click="openCompenyDetail(scope.row.id,'2')">编辑</label>
            <label class="linkLable">删除</label>
          </template>
        </vxe-table-column>
      </vxe-table>
      <vxe-pager
        :current-page.sync="tableCurrentPage"
        :page-size.sync="pageSize"
        :total="total"
        :layouts="['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'FullJump', 'Total']"
        @page-change="getRentList()"
      />
    </div>
    <companyDetail ref="companyDetail" :parent-id="rowData.id" :disabled="disabled" />
  </el-dialog>
</template>

<script>
import SearchButton from '@/components/SearchButton'
import companyDetail from './companyDetail'
export default {
  components: {
    SearchButton,
    companyDetail
  },
  props: {
    btnCheck: {
      type: Boolean,
      required: true
    },
    operateCheck: {
      type: Boolean,
      required: true
    }
  },
  data() {
    return {
      queryCondition: {}, // 查询条件
      companyDialogVisible: false, // 公司列表 modal开关
      loading: false,
      companyList: [],
      tableCurrentPage: 1,
      pageSize: 20,
      total: 0,
      disabled: false,
      rowData: {}
    }
  },
  methods: {
    refreshParams(params) {},
    getList1() {},
    openCompenyDetail(id, type) {
      if (this.type !== '0') {
        this.rowData.id = id
        if (type === '1') {
          this.disabled = true
        } else {
          this.disabled = false
        }
      }
      this.$refs.companyDetail.dialogVisible = true
    }
  }
}
</script>

<style lang="scss">

</style>
